<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        客户详情
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../lib/loading/okLoading.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
</head>
<!--借还流水-->
<style>
    .layui-form-label {
        width: 150px !important;
    }
</style>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" id="app">
    <form class="layui-form layui-form-pane" id="add">
        <div class="layui-tab-content">
            <h2>基本信息</h2>
            <div class="layui-tab-item layui-show">
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label" id="hkrq"> <span class='x-red'>*</span>客户名称</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" id="name" name="name" v-model="" lay-verify="required" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label" > <span class='x-red'>*</span>识别代码</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" id="code" name="code" v-model="" lay-verify="required" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" id="area-picker">
                    <div class="layui-form-label">省市地区</div>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select name="province" class="province-selector" data-value="广东省" lay-filter="province-1">
                            <option value="">请选择省</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select name="city" class="city-selector" data-value="深圳市" lay-filter="city-1">
                            <option value="">请选择市</option>
                        </select>
                    </div>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select name="county" class="county-selector" data-value="龙岗区" lay-filter="county-1">
                            <option value="">请选择区</option>
                        </select>
                    </div>
                </div>
            </div>
            <h2>执照照片</h2>
            <div class="layui-upload">
                <button type="button" class="layui-btn" id="test1">上传图片</button><input  autocomplete="off"  class="layui-upload-file" type="file" accept="" name="file">
                <div class="layui-upload-list">
                    <img class="layui-upload-img" id="demo1" width="250" height="250">
                    <p id="demoText"></p>
                </div>
            </div>
            <h2>备注信息</h2>

            <div class="layui-form-item layui-form-text">

                <div class="layui-input-block">
                    <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>


                <div style="text-align: center" class="layui-form-item">
                    <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                        保存
                    </button>
                </div>
                <!--</form>-->
                <div style="height:20px;"></div>
            </div>

    </form>
</div>
<script type="text/javascript" src="../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../js/pub.js"></script>
<script src="../../../lib/layui/layui2.5.7.js" charset="utf-8"></script>
<script src="../../../js/x-layui.js" charset="utf-8"></script>
<script src="../../../js/vue.min.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
    layui.use(['element', 'layer', 'form', 'laydate'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        laydate = layui.laydate;//日期插件
        form = layui.form;
        okLoading.close($);
    })
</script>
<script>
    //配置插件目录
    layui.config({
        base: '../../../js/'
        , version: '1.0'
    });
</script>
<script>

    var recordId = getQueryVariable("recordId");
    var type = getQueryVariable("type");


    layui.use(['laydate', 'form', 'layer','layarea','upload'],
        function () {
            var laydate = layui.laydate;
            var $ = layui.jquery;
            var form = layui.form;
            var layer = layui.layer;
            var layarea = layui.layarea;
            var upload = layui.upload;

            //普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                ,url: 'https://httpbin.org/post' //改成您自己的上传接口
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败');
                    }
                    //上传成功
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });

            layarea.render({
                elem: '#area-picker',
                // data: {
                //     province: '广东省',
                //     city: '深圳市',
                //     county: '龙岗区',
                // },
                change: function (res) {
                    //选择结果
                    console.log(res);
                }
            });

            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    let form = data.field;
                    form.userId = $userId;
                    form.addUserId = $userId;
                    form.id = vm.borrowAndReturnWater.id;
                    form.capitalAccountId = form.capitalAccount;
                    form.capitalAccount = $("select[name=capitalAccount]").find("option:selected").text()


                    let request = {
                        url: 'borrowAndReturnWater/addBorrowAndReturnWater',
                        data: form,
                        method: "post",
                    };
                    sendRequest(request, (data) => {
                        if (data.code === 0) {
                            layer.alert("操作成功", {
                                    icon: 6
                                },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.reload();

                                });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    });
                    return false;
                });


        });

</script>

</body>

</html>
